import React from 'react'
class Test extends React.Component {
  constructor(props) {
    super(props)
    this.state = {
      movies: [
        {
          name: '能不能',
          count: 1,
        },
        {
          name: '会不会',
          count: 2,
        },
        {
          name: '加不加',
          count: 3,
        },
      ],
      nums: [22, 11, 33, 9, 221],
    }
  }
  movieCountClick = item => {
    item.count += 1
    this.setState({})
  }
  render() {
    const { movies } = this.state

    return (
      <>
        {movies.map(moive => {
          return (
            <div key={moive.name}>
              <div style={{ backgroundColor: '#567', textAlign: 'center' }}>{moive.name}</div>
              <div style={{ textAlign: 'center' }}>
                <span style={{ padding: '0 10px' }}>{moive.count}</span>
                <button onClick={() => this.movieCountClick(moive)}>{'+1'}</button>
              </div>
            </div>
          )
        })}
        <hr />
      </>
    )
  }
}

export default Test
